<?php
namespace Api\Logic;


class UserLogic
{

    public function register($username,$password){
        $userModel = D('Home/User'); //M('user')
        $user=array();
        $user['username']=$username;
        $user['password']=$password;

        if ($userModel->where(array('username'=>$username))->count()>0){
          return -1;
        }

        $uid=$userModel->add($user);             
        if ($uid) {
           return $uid;
        } else {
            return -2;
        }
    }

}